package com.example.partyfee.repository;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.partyfee.entity.Salary;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 工资数据访问层
 */
@Mapper
public interface SalaryRepository extends BaseMapper<Salary> {
    /**
     * 获取所有工资月份列表
     *
     * @return 月份列表（格式：yyyy-MM）
     */
    @Select("SELECT DISTINCT month FROM salary ORDER BY month DESC")
    List<String> findAllMonths();

    /**
     * 根据身份证号和月份范围查询工资数据
     *
     * @param idCard 身份证号
     * @param startMonth 开始月份 (yyyy-MM)
     * @param endMonth 结束月份 (yyyy-MM)
     * @return 工资数据列表
     */
    @Select("SELECT * FROM salary WHERE id_card = #{idCard} AND month BETWEEN #{startMonth} AND #{endMonth}")
    List<Salary> findByIdCardAndMonthBetween(String idCard, String startMonth, String endMonth);

    @Select("SELECT * FROM salary WHERE month BETWEEN #{startMonth} AND #{endMonth}")
    List<Salary> findByMonthBetween(String startMonth, String endMonth);
} 